package com.yumijinfu.view.banner;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.yumijinfu.R;
import com.yumijinfu.util.GlideHelper;
import com.yumijinfu.view.banner.holder.Holder;


/**
 * Created by Sai on 15/8/4.
 * 网络图片加载例子
 */
public class NetworkImageHolderView implements Holder<String> {
    private ImageView imageView;
    private View view;
    private Activity activity;

    public NetworkImageHolderView(Activity activity) {
        this.activity = activity;
    }

    @Override
    public View createView(Context context) {
//你可以通过layout文件来创建，也可以像我一样用代码创建，不一定是Image，任何控件都可以进行翻页
//        WindowManager wm =activity.getWindowManager();
//        int width = wm.getDefaultDisplay().getWidth();
        imageView = new ImageView(context);
//        imageView.setAdjustViewBounds(true);
//        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
//        width, LinearLayout.LayoutParams.WRAP_CONTENT);
//        imageView.setLayoutParams(layoutParams);
//        imageView.setMaxWidth(width);
//        imageView.setMaxHeight(width);
//        imageView.setScaleType(ImageView.ScaleType.FIT_XY);
//        view= LayoutInflater.from(context).inflate(R.layout.banner_imageview,null);
//        imageView= (ImageView) view.findViewById(R.id.banner_imageview);
        return imageView;
    }

    @Override
    public void UpdateUI(Context context, int position, String data) {
        imageView.setImageResource(R.mipmap.ic_launcher);
        GlideHelper.showImage(context, data, R.mipmap.ic_launcher, imageView);
//        Glide.with(context).load(data).into(imageView);
    }
}
